//
//  DCImageAndTextLabel.m
//  Driver
//
//  Created by 大橙子 on 2018/11/6.
//  Copyright © 2018 Tomous. All rights reserved.
//

#import "DCImageAndTextLabel.h"
@interface DCImageAndTextLabel ()

@end
@implementation DCImageAndTextLabel
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    return self;
}
-(void)setUpUI
{
    UIImageView *imageView = [[UIImageView alloc]init];
//    imageView.backgroundColor = [UIColor redColor];
    self.imageView = imageView;
    [self addSubview:imageView];
    
    UILabel *textLabel = [[UILabel alloc]init];
//    textLabel.backgroundColor = [UIColor yellowColor];
    textLabel.font = FONT(14);
    self.textLabel = textLabel;
    [self addSubview:self.textLabel];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat kMargin = 10;
    self.imageView.height = self.height - kMargin;
    self.imageView.width = self.imageView.height;
    self.imageView.x = 0;
    self.imageView.y = kMargin/2;
    
    self.textLabel.frame = CGRectMake(self.imageView.right+3, 0, self.width - self.imageView.width, self.height);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
